package leetcodecompetition.D341;

public class T6350 {
    public int maxDivScore(int[] nums, int[] divisors) {


        int maxSum=0;
        int maxVal=divisors[0];
        for (int i = 0; i <divisors.length ; i++) {

            int sum=0;
            for (int j = 0; j <nums.length ; j++) {
                if (nums[j]%divisors[i]==0)sum++;
            }
            if (sum>maxSum){
                maxSum=sum;
                maxVal=divisors[i];
            }
            if (sum==maxSum){
                maxVal=Math.min(maxVal,divisors[i]);
            }
        }
        return maxVal;
    }
}
